//
//  YYLabel+Utils.m
//  WXReader
//
//  Created by LL on 2021/9/10.
//  Copyright © 2021 Andrew. All rights reserved.
//

#import "YYLabel+Utils.h"

@implementation YYLabel (Utils)

- (CGFloat)w_textWidth {
    if (self.attributedText) {
        return [TL_ViewHelper calcTextSize:CGSizeMake(CGFLOAT_MAX, 30.0)
                                 text:self.attributedText
                        numberOfLines:1
                                 font:nil
                        textAlignment:self.attributedText.alignment
                        lineBreakMode:self.attributedText.lineBreakMode
                   minimumScaleFactor:0
                         shadowOffset:CGSizeZero].width;
    }
    
    return [TL_ViewHelper calcTextSize:CGSizeMake(CGFLOAT_MAX, 30.0)
                             text:self.text
                    numberOfLines:1
                             font:self.font
                    textAlignment:self.textAlignment
                    lineBreakMode:self.lineBreakMode
               minimumScaleFactor:0
                     shadowOffset:CGSizeZero].width;
}

- (CGFloat)w_textHeight {
    if (self.attributedText) {
        return [TL_ViewHelper calcTextSize:CGSizeMake(self.preferredMaxLayoutWidth, CGFLOAT_MAX)
                                 text:self.attributedText
                        numberOfLines:self.numberOfLines
                                 font:nil
                        textAlignment:self.attributedText.alignment
                        lineBreakMode:self.attributedText.lineBreakMode
                   minimumScaleFactor:0
                         shadowOffset:CGSizeZero].height;
    }
    
    return [TL_ViewHelper calcTextSize:CGSizeMake(self.preferredMaxLayoutWidth, CGFLOAT_MAX)
                             text:self.text
                    numberOfLines:self.numberOfLines
                             font:self.font
                    textAlignment:self.textAlignment
                    lineBreakMode:self.lineBreakMode
               minimumScaleFactor:0
                     shadowOffset:CGSizeZero].height;
}

@end
